package net.imagine.backend.mockrmi.remote.provider.mina.server;

import net.imagine.backend.mockrmi.remote.server.Server;
import net.imagine.backend.mockrmi.remote.server.ServerFactory;

import org.apache.commons.collections.FastHashMap;

/**
 * 使用Mina框架实现的ServerFactory，用于创建Mina的实现的Server对象
 * 
 * @author wuqh
 * @see ServerFactory
 * @see MinaServer
 */
public class MinaServerFactory implements ServerFactory {
	private FastHashMap servers;

	public MinaServerFactory() {
		servers = new FastHashMap();
		servers.setFast(true);
	}

	public Server getServer(int port) {
		MinaServer server = (MinaServer) servers.get(port);
		if (server == null) {
			server = new MinaServer(port);
			servers.put(port, server);
		}
		return server;
	}
}
